package com.mdd.front.service.log.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mdd.common.entity.log.OrderRefundLog;
import com.mdd.common.mapper.log.OrderRefundLogMapper;
import com.mdd.front.service.log.IOrderRefundLogService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 订单退款日志实现类
 */
@Service
public class OrderRefundLogServiceImpl extends ServiceImpl<OrderRefundLogMapper, OrderRefundLog> implements IOrderRefundLogService {

    @Resource
    OrderRefundLogMapper orderRefundLogMapper;

    @Override
    public void saveEntity(OrderRefundLog refundLog) {
        super.save(refundLog);
    }

    @Override
    public OrderRefundLog getByWechatRefundId(String wechatRefundId) {
        LambdaQueryWrapper<OrderRefundLog> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(OrderRefundLog::getWechatRefundId, wechatRefundId);
        lambdaQueryWrapper.last("limit 1");
        return super.getOne(lambdaQueryWrapper);
    }

    @Override
    public void updateEntityById(OrderRefundLog log) {
        super.updateById(log);
    }
}
